package com.ruoyi.web.controller.form.api;

import com.ruoyi.common.utils.http.HttpUtils;
import com.ruoyi.common.utils.security.Md5Utils;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.Random;

public class Test {

    public static void main(String[] args) {
        String str = "0 */5 * * * ?";
        Random random = new Random();
        int randomNumber = random.nextInt(5) + 1;
        String s = str.substring(0, 4) + randomNumber + str.substring(5);
        System.out.println(s);
    }

//    public static void main(String[] args) throws Exception{
//        String url = "https://cxh.njxt88.cn/newbiz/api/v1/qlc/userCheck/52f930e05";
//        String hash = Md5Utils.hash("18723123114");
//        System.out.println(hash);
//        try {
//            // 目标URL，参数通过路径传递
//            URL url1 = new URL(url);
//
//            // 打开连接
//            HttpURLConnection connection = (HttpURLConnection) url1.openConnection();
//            connection.setRequestMethod("POST");
//
//            // 设置请求头信息，如内容类型
//            connection.setRequestProperty("Content-Type", "application/json");
//
//            // 设置允许输入输出
//            connection.setDoOutput(true);
//
//            // 请求体内容，如果有的话
//            String param = "{\n" +
//                    "\t\"city\":\"哈密市\",\n" +
//                    "\t\"province\":\"新疆维吾尔族自治区\",\n" +
//                    "\t\"ipAddress\":\"127.0.0.1\",\n" +
//                    "\t\"userPhoneMd5\":\"32886deeaa9988c44907cc62a8c377e4\",\n" +
//                    "\t\"name\":\"小明2\",\n" +
//                    "\t\"sex\":1,\n" +
//                    "\t\"age\":17,\n" +
//                    "\t\"monthlyIncome\":1,\n" +
//                    "\t\"loanAmount\":1,\n" +
//                    "\t\"qualification\":1,\n" +
//                    "\t\"profession\":1,\n" +
//                    "\t\"gjj\":1,\n" +
//                    "\t\"socialInsurance\":1,\n" +
//                    "\t\"house\":1,\n" +
//                    "\t\"car\":1,\n" +
//                    "\t\"sesame\":1,\n" +
//                    "\t\"insurancePolicy\":1,\n" +
//                    "\t\"payType\":1,\n" +
//                    "\t\"creditCard\":1,\n" +
//                    "\t\"idCard\":\"332123128932183129\"\n" +
//                    "}";
//            //String requestBody = "{\"key1\":\"value1\",\"key2\":\"value2\"}";
//            byte[] outputInBytes = param.getBytes("UTF-8");
//            OutputStream os = connection.getOutputStream();
//            os.write(outputInBytes);
//            os.close();
//
//            // 获取响应码
//            int responseCode = connection.getResponseCode();
//            System.out.println("Response Code: " + responseCode);
//
//            // 读取响应内容
//            if (responseCode == HttpURLConnection.HTTP_OK) { // 200
//                BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8));
//                String inputLine;
//                StringBuilder response = new StringBuilder();
//
//                while ((inputLine = in.readLine()) != null) {
//                    response.append(inputLine);
//                }
//
//                in.close();
//
//                // 打印结果
//                System.out.println(response.toString());
//            }
//
//
//            // 关闭连接
//            connection.disconnect();
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//
//
//
//
//        String url2 = "https://cxh.njxt88.cn/newbiz/api/v1/qlc/userRegister/52f930e05";
//
//        try {
//            // 目标URL，参数通过路径传递
//            //String targetURL = "http://example.com/api/resource?param1=value1&param2=value2";
//            URL url1 = new URL(url2);
//
//            // 打开连接
//            HttpURLConnection connection = (HttpURLConnection) url1.openConnection();
//            connection.setRequestMethod("POST");
//
//            // 设置请求头信息，如内容类型
//            connection.setRequestProperty("Content-Type", "application/json");
//
//            // 设置允许输入输出
//            connection.setDoOutput(true);
//
//            // 请求体内容，如果有的话
//            String param = "{\n" +
//                    "\t\"city\":\"哈密市\",\n" +
//                    "\t\"province\":\"新疆维吾尔族自治区\",\n" +
//                    "\t\"ipAddress\":\"127.0.0.1\",\n" +
//                    "\t\"userPhone\":\"18723123112\",\n" +
//                    "\t\"name\":\"小明\",\n" +
//                    "\t\"sex\":1,\n" +
//                    "\t\"age\":16,\n" +
//                    "\t\"monthlyIncome\":1,\n" +
//                    "\t\"loanAmount\":1,\n" +
//                    "\t\"loanTerm\":1,\n" +
//                    "\t\"qualification\":1,\n" +
//                    "\t\"profession\":1,\n" +
//                    "\t\"gjj\":1,\n" +
//                    "\t\"socialInsurance\":1,\n" +
//                    "\t\"house\":1,\n" +
//                    "\t\"car\":1,\n" +
//                    "\t\"sesame\":1,\n" +
//                    "\t\"insurancePolicy\":1,\n" +
//                    "\t\"payType\":1,\n" +
//                    "\t\"creditInformation\":1,\n" +
//                    "\t\"idCard\":\"332123128932183129\"\n" +
//                    "}";
//            //String requestBody = "{\"key1\":\"value1\",\"key2\":\"value2\"}";
//            byte[] outputInBytes = param.getBytes("UTF-8");
//            OutputStream os = connection.getOutputStream();
//            os.write(outputInBytes);
//            os.close();
//
//            // 获取响应码
//            int responseCode = connection.getResponseCode();
//            System.out.println("Response Code: " + responseCode);
//
//            // 读取响应内容
//            if (responseCode == HttpURLConnection.HTTP_OK) { // 200
//                BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8));
//                String inputLine;
//                StringBuilder response = new StringBuilder();
//
//                while ((inputLine = in.readLine()) != null) {
//                    response.append(inputLine);
//                }
//
//                in.close();
//
//                // 打印结果
//                System.out.println(response.toString());
//            }
//
//            // 关闭连接
//            connection.disconnect();
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//
//    }

//    public static void main(String[] args) throws Exception{
//        String url = "https://cxh.njxt88.cn/newbiz/api/v1/qlc/userRegister/52f930e05";
//
//        try {
//            // 目标URL，参数通过路径传递
//            //String targetURL = "http://example.com/api/resource?param1=value1&param2=value2";
//            URL url1 = new URL(url);
//
//            // 打开连接
//            HttpURLConnection connection = (HttpURLConnection) url1.openConnection();
//            connection.setRequestMethod("POST");
//
//            // 设置请求头信息，如内容类型
//            connection.setRequestProperty("Content-Type", "application/json");
//
//            // 设置允许输入输出
//            connection.setDoOutput(true);
//
//            // 请求体内容，如果有的话
//            String param = "{\n" +
//                    "\t\"city\":\"哈密市\",\n" +
//                    "\t\"province\":\"新疆维吾尔族自治区\",\n" +
//                    "\t\"ipAddress\":\"127.0.0.1\",\n" +
//                    "\t\"userPhone\":\"18723123112\",\n" +
//                    "\t\"name\":\"小明\",\n" +
//                    "\t\"sex\":1,\n" +
//                    "\t\"age\":18,\n" +
//                    "\t\"monthlyIncome\":1,\n" +
//                    "\t\"loanAmount\":1,\n" +
//                    "\t\"loanTerm\":1,\n" +
//                    "\t\"qualification\":1,\n" +
//                    "\t\"profession\":1,\n" +
//                    "\t\"gjj\":1,\n" +
//                    "\t\"socialInsurance\":1,\n" +
//                    "\t\"house\":1,\n" +
//                    "\t\"car\":1,\n" +
//                    "\t\"sesame\":1,\n" +
//                    "\t\"insurancePolicy\":1,\n" +
//                    "\t\"payType\":1,\n" +
//                    "\t\"creditInformation\":1,\n" +
//                    "\t\"idCard\":\"332123128932183129\"\n" +
//                    "}";
//            //String requestBody = "{\"key1\":\"value1\",\"key2\":\"value2\"}";
//            byte[] outputInBytes = param.getBytes("UTF-8");
//            OutputStream os = connection.getOutputStream();
//            os.write(outputInBytes);
//            os.close();
//
//            // 获取响应码
//            int responseCode = connection.getResponseCode();
//            System.out.println("Response Code: " + responseCode);
//
//            // 读取响应内容
//            if (responseCode == HttpURLConnection.HTTP_OK) { // 200
//                BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8));
//                String inputLine;
//                StringBuilder response = new StringBuilder();
//
//                while ((inputLine = in.readLine()) != null) {
//                    response.append(inputLine);
//                }
//
//                in.close();
//
//                // 打印结果
//                System.out.println(response.toString());
//            }
//
//            // 关闭连接
//            connection.disconnect();
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//
//
//
//
//
//
//
////        // 参数通过查询字符串传递
////        String param = "city=南京&province=江苏&ipAddress=127.0.0.1&userPhone=187231231" +
////                "&name=小明&sex=0&age=18&monthlyIncome=1&loanAmount=1" +
////                "&loanTerm=3&qualification=1&profession=1&gjj=1" +
////                "&socialInsurance=1&house=1&car=1&sesame=1&insurancePolicy=1" +
////                "&payType=1&creditInformation=1&creditCard=1&idCard=332123128932183129";
//
////        URL obj = new URL(url + "?" + param);
////        HttpURLConnection con = (HttpURLConnection) obj.openConnection();
////
////        // 设置请求类型
////        con.setRequestMethod("POST");
////
////        // 添加请求头
////        con.setRequestProperty("User-Agent", "Mozilla/5.0");
////        con.setRequestProperty("contentType", "utf-8");
////
////        int responseCode = con.getResponseCode();
////        System.out.println("POST Response Code :: " + responseCode);
////
////        if (responseCode == HttpURLConnection.HTTP_OK) { // 200
////            BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), StandardCharsets.UTF_8));
////            String inputLine;
////            StringBuilder response = new StringBuilder();
////
////            while ((inputLine = in.readLine()) != null) {
////                response.append(inputLine);
////            }
////
////            in.close();
////
////            // 打印结果
////            System.out.println(response.toString());
////        } else {
////            System.out.println("POST request not worked");
////        }
//
//
//
//
////        String param = "city=南京&province=江苏&ipAddress=127.0.0.1&userPhone=187231231" +
////                "&name=小明&sex=0&age=18&monthlyIncome=1&loanAmount=1" +
////                "&loanTerm=3&qualification=1&profession=1&gjj=1" +
////                "&socialInsurance=1&house=1&car=1&sesame=1&insurancePolicy=1" +
////                "&payType=1&creditInformation=1&creditCard=1&idCard=332123128932183129";
////        String param = "{\n" +
////                "\t\"city\":\"南京\",\n" +
////                "\t\"province\":\"江苏\",\n" +
////                "\t\"ipAddress\":\"127.0.0.1\",\n" +
////                "\t\"userPhone\":\"18723123112\",\n" +
////                "\t\"name\":\"小明\",\n" +
////                "\t\"sex\":1,\n" +
////                "\t\"age\":1,\n" +
////                "\t\"monthlyIncome\":1,\n" +
////                "\t\"loanAmount\":1,\n" +
////                "\t\"loanTerm\":1,\n" +
////                "\t\"qualification\":1,\n" +
////                "\t\"profession\":1,\n" +
////                "\t\"gjj\":1,\n" +
////                "\t\"socialInsurance\":1,\n" +
////                "\t\"house\":1,\n" +
////                "\t\"car\":1,\n" +
////                "\t\"sesame\":1,\n" +
////                "\t\"insurancePolicy\":1,\n" +
////                "\t\"payType\":1,\n" +
////                "\t\"creditInformation\":1,\n" +
////                "\t\"idCard\":\"332123128932183129\"\n" +
////                "}";
////        String s = HttpUtils.sendPost(url, param);
////        System.out.println(s);
//    }

}
